<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //  深度比较
    function isObj(obj) {
      return typeof obj === 'object' && obj !== null
    }
    function isEqual(obj1, obj2) {
      if (!isObj(obj) || !isObj(obj2)) {
        return obj1 === obj2
      }

      if (obj1 === obj2) {
        return true
      }

      let obj1Keys = Object.keys(obj1)
      let obj2Keys = Object.keys(obj2)
      if (obj1Keys.length !== obj2Keys.length) {
        return false
      }

      for (let key in obj1) {
        const res = isEqual(obj1[key], obj2[key])
        if (!res) {
          return false
        }
      }
      return true
    }
  </script>
</body>

</html>